package com.itheima.service.impl;

import com.itheima.service.AccountService;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;


//@Service("accountServiceImpl")// 等价于XML文件中的 <bean id="accountServiceImpl" class="com.itheima.service.impl.AccountServiceImpl"/>
@Component("accountServiceImpl")
@Scope("singleton")//单例模式
public class AccountServiceImpl implements AccountService {
    public void add() {
        System.out.println("abb run -------");
    }

    @PostConstruct //等价于 init-method="init" 初始化方法
    public void init() {
        System.out.println("init run-------");
    }
    @PreDestroy //等价于 destroy-method="destroy" 销毁时运行的方法
    public void destroy() {
        System.out.println("destroy run -----");
    }

}
